<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/taglib/common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>文件预览界面</title>
<%@ include file="/WEB-INF/view/taglib/header.jsp"%>
<%@ include file="/WEB-INF/view/taglib/easyui.jsp"%>
<%@ include file="/WEB-INF/view/taglib/layer.jsp"%>
<%@ include file="/WEB-INF/view/taglib/uedit.jsp"%>
</head>
<body>
	<div
		style="position: absolute; top: 10px; left: 20px; right: 20px; bottom: 10px;">

	</div>
	<script type="text/javascript">
    	// 获取项目访问路径
	    function getRootPath() {  
	        var pathName = window.location.pathname.substring(1);  
	        var webName = pathName == '' ? '' : pathName.substring(0, pathName.indexOf('/'));  
	        return window.location.protocol + '//' + window.location.host + '/' + webName + '/';  
	    } 
	    $(document).ready(function(){
	    	var fileName = '<%=new String(request.getParameter("fileName"))%>';
							console.log(fileName);
							var url = getRootPath();
							$.ajax({
										type : "post",
										url : "${ctx}/fileOnline/onlinePreview",
										data : {
											url : url + "upload/preview/demo/"+ fileName
										},
										dataType : 'json',
										success : function(data) {
											debugger;
											var dataMsg = data.message;
											var jsonMsg = eval(dataMsg);
											var jsonData = jsonMsg[0];
											var fileName = "";
											var fileSuffix;
											var jsonFileName = jsonData.url
													.split(".");
											for (var i = 0; i < jsonFileName.length; i++) {
												if (i == jsonFileName.length - 1) {
													fileSuffix = jsonFileName[i];
												} else {
													fileName += jsonFileName[i]+ ".";
												}
											}
											var type = jsonData.type;
											if (jsonData.type == "picture") {
												type = "";
												fileName = jsonData.url;
											}
											window.location.href = url+ 'upload/preview/'+ fileName + type;
										}
									});
						});
	</script>
</body>
</html>
